import oss2
import yaml

print(oss2.__version__)

with open("/Users/daidongyang/tmp/aliyunapi.yaml") as yaml_file:
    yam_obj = yaml.safe_load(yaml_file)
    if "access_key_id" in yam_obj:
        access_key_id = yam_obj["access_key_id"]
    else:
        raise RuntimeError("access_key_id is not found")
    if "access_key_secret" in yam_obj:
        access_key_secret = yam_obj["access_key_secret"]
    else:
        raise RuntimeError("access_key_secret is not found")

auth = oss2.Auth(access_key_id, access_key_secret)

bucket = oss2.Bucket(auth, 'http://oss-cn-shenzhen-internal.aliyuncs.com', 'zdiai-backup-shenzhen')

#bucket.put_object_from_file('1.jpg', '/Users/daidongyang/Pictures/上海.jpeg')
file = "msgcenter"

url = bucket.sign_url("GET", file, 5 * 60)

print(url)